package struct.intermediate.queue;

import struct.primary.array.Array;

/**
 * @author MAX
 * @version 1.0
 * @description 中级数据结构-动态数组队列，缺陷：出队复杂度O(n)
 * @date 2022/1/13 10:55
 */
public class ArrayQueue<E> implements Queue<E> {

    private Array<E> data;

    public ArrayQueue() {
        data = new Array<>();
    }

    @Override
    public void enqueue(E e) {
        data.addLast(e);
    }

    @Override
    public E dequeue() {
        return data.removeFirst();
    }

    @Override
    public E getFront() {
        return data.get(0);
    }

    @Override
    public int size() {
        return data.size();
    }

    @Override
    public boolean isEmpty() {
        return data.isEmpty();
    }

    @Override
    public String toString() {
        return "front " + data.toString() + " tail";
    }
}
